﻿using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Screens2.Renders.Windows
{
    public class EntityListScreenRenderer : IEntityListScreenRenderer
    {
        public void RenderParentClass(EntityListScreen control, CodeWriter writer)
        {
            //writer.Write(string.Format("ListEntityViewModel<{0}Model, {0}Entity>", control.EntityName));
        }


        public void RenderCode(EntityListScreen control, CodeWriter writer)
        {
            writer.Write(string.Format(@"
        public {0}ListEntityView()
        {{
            InitializeComponent();
        }}

        public new {0}ListEntityViewModel ViewModel
        {{
            get {{ return base.ViewModel as {0}ListEntityViewModel; }}
            set {{ base.ViewModel = value; }}
        }}
", control.EntityName));
        }

        public void RenderControls(EntityListScreen control, CodeWriter writer)
        {
            writer.WriteFullTag("Grid");
            writer.WriteFullTag("phone:Pivot");

            control.Header.RenderUiXmlBegin(writer);

            control.ListBox.RenderUiXml(writer);

            control.Header.RenderUiXmlEnd(writer);

            writer.WriteEndTag("phone:Pivot");

            control.ActionBar.RenderUiXml(writer);
            writer.WriteEndTag("Grid");
        }

    }
}
